$(function() {
	$('#vue_vm_list div').hide();
});

var filialScore = {
	filialScoreId: '',
	elderId: '',
	familyMemberId: '',
	year: '',
	month: '',
	score: '',
	createTime: '',
	updateTime: '',
	createId: getLoginedUser()? getLoginedUser().staffId: '',
	updateId: getLoginedUser()? getLoginedUser().staffId: '',
};

var view = {
	data: filialScore
};

var vue_vm = new Vue({
	el: '#vue_vm',
	data: view
});

function save() {
	if(view.data.elderId=='') {
		alert('请选择长者');
		return;
	}
	
	if(view.data.familyMemberId=='') {
		alert('请选择长者家属');
		return;
	}
	
	if(view.data.year=='') {
		alert('请输入年份');
		return;
	}
	
	if(view.data.month=='') {
		alert('请选择月份');
		return;
	}
	
	if(view.data.score=='') {
		alert('请选择分数');
		return;
	}
	
	filialScore.elderId = view.data.elderId;
	filialScore.familyMemberId = view.data.familyMemberId;
	filialScore.year = parseInt(view.data.year);
	filialScore.month = parseInt(view.data.month);
	filialScore.score = parseInt(view.data.score);
	
	save_basic(path+'/filialScore/save', {filialScore:filialScore}, function() {
		alert('保存成功');
	});
}

function filialScoreFind() {
	if($('#vue_vm_list').length==0) {return;}
	$('#vue_vm_list div').hide();
	var month = $('#year').val() + '-' + $('#month').val();
	var elderSearchVal = $('#elderSearchVal').val();

	find_basic_by_json(path+'/filialScore/find',
			{month: month, elderSearchVal: elderSearchVal}, function(response) {
		$('#vue_vm_list').html(gl_vue_vm_list_html);
		
		new Vue({
			el: '#vue_vm_list',
			data: {
				todos: [response.data.elderForm]
			}
		});
		
		$('#vue_vm_list div').show();
	});
}

function deleteBatch() {
	deleteBatch_basic(path+'/filialScore/deleteBatch');
}
